package com.jiangdg.usbcamera.utils;


import android.content.Context;
import android.util.Log;

import com.loopj.android.http.AsyncHttpClient;
import com.loopj.android.http.AsyncHttpResponseHandler;
import com.loopj.android.http.JsonHttpResponseHandler;
import com.loopj.android.http.RequestParams;

import cz.msebera.android.httpclient.HttpEntity;

public class HttpUtils {

    public static AsyncHttpClient asynClient = new AsyncHttpClient();//异步请求
    static {
        asynClient.setTimeout(21000);// 请求超时时间

    }

    public static void httpPostMethod(String url, AsyncHttpResponseHandler responseHandler) {
        asynClient.post(url, responseHandler);
    }

    public static void httpPostJsonMethod(Context mContext, String url, HttpEntity entity , String info, JsonHttpResponseHandler result) {
        asynClient.post(mContext,url,entity,info,result);
        Log.d("HTTP:",url.toString());
        Log.d("BODY:",entity.toString());
    }

    public static void httpPostMethod(String url, RequestParams params, AsyncHttpResponseHandler responseHandler) {

        asynClient.post(url,params ,responseHandler);
    }
    public static void httpGeTMethod(Context mContext,String url,HttpEntity entity , String info, AsyncHttpResponseHandler responseHandler) {
        asynClient.get(mContext,url,entity,info,responseHandler);
    }

    public static void httpGet(String url , RequestParams pa, JsonHttpResponseHandler result){
        asynClient.get(url,pa,result);
    }
}
